MNE-Python compatibility layer (epic #139) - #191
Conversation
* Add AMICAICA MNE wrapper (single-model) * Add MNE wrapper tests and CI job * Document AMICAICA MNE wrapper * Harden AMICAICA: atomic fit, guards, degenerate refusal * Test eigen-order, guards, save-reload, refit safety * Document plot_sources, PCA-reduction limit, guards * Fix typo flagged by typos CI
* Add public model_loglik/model_probability accessors * Let plot_model_probability accept a live lht array * Expose multi-model AMICA through AMICAICA * Document multi-model MNE wrapper * Guard scoring path: finiteness, underflow, docstrings * Harden AMICAICA multi-model: kw-only model_idx, guards, tests * Fix stale Notes mapping doc; add viz/docs coverage
* Expose MIR/PMI metrics through AMICAICA * Test MNE-wrapper MIR/PMI accessors * Document MIR/PMI accessors * Pin pmi-on-epochs, nbins, degenerate guard for metrics
Integrated review (Sonnet, cross-phase)Ran a focused review over the combined 4-phase diff for integration/coherence issues (beyond the per-phase reviews on #187-#190). The layering checked out: guard ordering ( Two findings:
CI re-running after the docstring commit. |
Summary
Adds an MNE-Python compatibility layer for pamica, additive throughout: the scikit-learn-style
AMICAAPI and the byte-identical EEGLAB I/O are unchanged. MNE-Python users get a native entry point viafrom pamica.mne_compat import AMICAICA, shipped as the optionalpamica[mne]extra soimport pamicanever requires MNE. Works with current MNE, no fork or extension.Closes #139.
Phases
AMICAICA.fit(raw/epochs, picks=...)andto_mne_ica()mapping pamica's mean/symmetric-ZCA sphere/unmixing into a realmne.preprocessing.ICA(round-tripsAMICA.transformto float64 precision);get_sources/apply/get_components/plot_components/plot_sourcesdelegate to it.mne.preprocessing.ICA(to_mne_ica(model_idx=...)); the per-sample model dominance MNE cannot represent is exposed viaget_model_probability/plot_model_probability, built on a new publicAMICA.model_loglik/model_probabilityaccessor (validated bit-for-bit against the E-step'sLht).get_pdftype/get_rho/shared_components+PDFTYPE_NAMES) surfaced rather than dropped by the ICA export.mir/pmi) callable directly on an MNE object.Design notes
ICA.cintopca_mean_; single-model (c=0) stays byte-identical.pca_components_is kept orthonormal (sphere written asV diag(1/sqrt(e)) V^T) so MNE's scalp maps come out in channel space.pcakeep/pcadb) is rejected (the export assumes full-rank whitening); non-finite input and degenerate fits are refused.Test plan
pamica/tests/mne_tests/(46 tests) run on the real bundledeeglab_data.setvia a dedicatedtest-mneCI job (uv sync --extra mne); the base job skips them viaimportorskip. New backend suites (test_ng_model_posterior.py,test_ng_metadata.py) run in base CI. No mocks.Merge
Per the repo policy, an epic PR uses a regular merge (not squash) to preserve the per-phase history.